<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>单复选按钮组件</title>
	<style>
		.box {
			margin: 0 auto;
			width: 500px;
		}

		.container {
			padding: 10px;
			/* border: 1px solid #333; */
			border-bottom: 1px solid #333;
			margin: 0 auto;
		}

		.checkbox {
			position: relative;
			display: block;
		}

		.checkbox input {
			position: absolute;
			top: 0;
			left: 0;
			visibility: hidden;
		}

		.checkbox label {
			position: relative;
			top: 0;
			left: 0;
			width: 30px;
			height: 30px;
			line-height: 30px;
			padding-left: 26px;
			user-select: none;
		}

		.checkbox label:before {
			position: absolute;
			left: 0;
			top: 50%;
			margin-top: -10px;
			width: 20px;
			height: 20px;
			text-align: center;
			line-height: 14px;
			content: '';
			border: 1px solid #333;
			display: block;
			font-size: 30px;
			color: #8c8;
		}

		.checkbox input[type="checkbox"]:checked+label:before {
			content: '√';
			border-color: #8c8;
		}

		.switch {
			position: relative;
			display: inline-block;
			min-height: 24px;
			margin-top: 6px;
		}

		.switch input[type="checkbox"] {
			box-sizing: border-box;
			left: 4px;
			margin: 0;
			padding: 0;
			position: absolute;
			top: 3px;
		}

		.switch input[type="checkbox"]+label {
			background-color: #e0e0e0;
			border-radius: 24px;
			cursor: pointer;
			display: inline-block;
			height: 24px;
			position: relative;
			text-indent: -9999px;
			-webkit-transition: background-color 0.3s;
			transition: background-color 0.3s;
			-webkit-user-select: none;
			-moz-user-select: none;
			-ms-user-select: none;
			user-select: none;
			width: 48px;
		}

		.switch input[type="checkbox"]+label:after {
			background-color: #fff;
			border-radius: 20px;
			content: " ";
			height: 20px;
			left: 2px;
			position: absolute;
			top: 2px;
			-webkit-transition: -webkit-transform 0.3s;
			-o-transition: -o-transform 0.3s;
			transition: transform 0.3s;
			width: 20px;
		}

		.switch input[type="checkbox"]:checked+label {
			background-color: #8c8;
		}

		.switch input[type="checkbox"]:checked+label:after {
			-webkit-transform: translateX(24px);
			-ms-transform: translateX(24px);
			-o-transform: translateX(24px);
			transform: translateX(24px);
		}

		.radio {
			position: relative;
		}

		.radio input {
			position: absolute;
			visibility: hidden;
		}

		.radio label {
			position: relative;
			display: inline-block;
			padding-left: 24px;
			height: 20px;
			line-height: 20px;
		}

		.radio label:before,
		.radio label:after {
			position: absolute;
			top: 50%;
			left: 0;
			content: '';
			box-sizing: border-box;
			border-radius: 50%;
		}

		.radio label:before {
			height: 20px;
			width: 20px;
			margin-top: -10px;
			border: 1px solid #000;
		}

		.radio input[type="radio"]:checked+label:before {
			border-color: #8c8;
		}

		.radio input[type="radio"]:checked+label:after {
			width: 14px;
			height: 14px;
			margin-top: -7px;
			margin-left: 3px;
			background-color: #8c8;
		}
	</style>

</head>

<body>
	<div class="box">
		<div class="container">
			<h2>单选按钮</h2>
			<div class="radio">
				<input id="man" name="sex" type="radio">
				<label for="man">男</label>
			</div>
			<div class="radio">
				<input id="women" name="sex" type="radio">
				<label for="women">女</label>
			</div>
		</div>
		<div class="container">
			<h2>复选按钮</h2>
			<span class="checkbox">
				<input id="checkbox1" type="checkbox" name="check">
				<label for="checkbox1">苹果</label>
			</span>
			<span class="checkbox">
				<input id="checkbox2" type="checkbox" name="check">
				<label for="checkbox2">香蕉</label>
			</span>
			<span class="checkbox">
				<input id="checkbox3" type="checkbox" name="check">
				<label for="checkbox3">橘子</label>
			</span>
		</div>
		<div class="container">
			<h2>移动端开关</h2>
			<div class="switch">
				<input id="c11" name="c1" type="checkbox">
				<label for="c11">Check</label>
			</div>
			<div class="switch">
				<input id="c12" name="c1" type="checkbox">
				<label for="c12">Check</label>
			</div>
		</div>
	</div>
</body>

</html>